Repository navigation
feat(auth)!: surface refresh-token availability on Credential/auth status - #79
Merged
Merged
Conversation
…atus PkceAuthProvider::status() only checks the access token's own expiry, so `auth status` reports a token as fully expired even when a valid refresh token is on file and the next real command would silently renew it without an interactive re-login. Adds Credential::refreshable (true when a refresh token is present), threaded through to AuthStatusEntry and AuthLoginResult so `auth status` and `auth login` output stays consistent. BREAKING CHANGE: Credential, AuthStatusEntry, and AuthLoginResult are public, non-exhaustive-less structs gaining a new field; any downstream struct literal constructing them without `..Default::default()` (or listing every field) will need updating.
There was a problem hiding this comment.
Pull request overview
This PR updates the cli_engine auth surface so auth status / auth login can report whether a cached credential is refreshable (i.e., a refresh token is present), avoiding the current “fully expired” interpretation when an access token is expired but can be silently refreshed.
Changes:
- Adds
Credential::refreshableand threads it throughAuthLoginResultandAuthStatusEntry. - Sets
Credential.refreshablefor PKCE-based credentials based on stored refresh-token presence. - Updates integration tests to account for the new public fields and JSON output shape.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
cli-engine/src/auth/credential.rs |
Adds Credential::refreshable with serde defaults and documentation. |
cli-engine/src/auth/pkce.rs |
Populates Credential.refreshable from the stored token’s refresh-token presence. |
cli-engine/src/auth/commands.rs |
Extends auth login / auth status output structs and wiring to include refreshable. |
cli-engine/tests/foundation.rs |
Updates assertions and public-surface construction tests for the new fields. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… coverage Copilot review on #79 flagged doc wording that read as a guarantee ("can be silently renewed", "will renew itself transparently") when refreshable only reflects that a refresh token was issued, not that a renewal attempt would succeed. Also adds the missing unit test coverage for build_credential setting refreshable from token.refresh_token.
Both are output-only DTOs built exclusively inside this crate (login_and_build_with_scopes/status_result/to_status_entry) — neither gddy nor gdx construct them via struct literal, unlike Credential (the AuthProvider trait's return type, built by hand in ~20 call sites across both consumers, which stays exhaustive for now). Adding this now, while #79 is already a breaking release, avoids needing another major bump the next time a field is added to either. Rewrites the two re-export smoke tests in foundation.rs to obtain instances through the real login/status flow instead of a struct literal, since non_exhaustive blocks that from outside the crate.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (1)
cli-engine/src/auth/commands.rs:19
- The PR description says
AuthLoginResult/AuthStatusEntryare public structs without#[non_exhaustive]and that the breaking change is only the newrefreshablefield. This diff also adds#[non_exhaustive], which is an additional breaking API change (external crates can no longer construct these structs via literals and cannot exhaustively destructure them). Either update the PR description/release notes to reflect this, or drop#[non_exhaustive]if it wasn’t intended.
/// result and should not construct it directly — `#[non_exhaustive]` lets
/// this framework add fields (as it did for [`refreshable`](Self::refreshable))
/// without another breaking release.
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
qcai-godaddy
approved these changes
Aug 4, 2026
Merged
jpage-godaddy
pushed a commit
that referenced
this pull request
Aug 4, 2026
🤖 I have created a release *beep* *boop* --- <details><summary>cli-engine: 0.7.0</summary> ## [0.7.0](cli-engine-v0.6.1...cli-engine-v0.7.0) (2026-08-04) ### ⚠ BREAKING CHANGES * **auth:** surface refresh-token availability on Credential/auth status ([#79](#79)) ### Features * **auth:** surface refresh-token availability on Credential/auth status ([#79](#79)) ([d88d30c](d88d30c)) * **command:** add opt-in pagination via CommandSpec::with_pagination ([#81](#81)) ([d829f90](d829f90)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
5 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PkceAuthProvider::status()only checks the access token's ownexpires_at, soauth statusreports a credential as fully expired even when a valid refresh token is on file and the next real command would silently renew it viaexisting_token()without an interactive re-login.Credential::refreshable: bool(token.refresh_token.is_some()), threaded through toAuthStatusEntry::refreshableandAuthLoginResult::refreshablesoauth status/auth loginoutput stays consistent with each other (mirrors the existingscopespattern).refreshablereflects presence, not verified validity — refresh tokens here are opaque with no discoverable TTL, so there's no way to confirm a refresh will succeed without attempting it. (Doc comments on all three types were reworded during review to state this explicitly rather than implying a renewal guarantee.)AuthLoginResultandAuthStatusEntry#[non_exhaustive](added during review). Both are output-only DTOs built exclusively inside this crate; neither gddy nor gdx construct them via struct literal, so this closes off needing another breaking release the next time a field is added to either.Credential(theAuthProvidertrait's return type, built by hand in ~20 call sites across both known consumers) is intentionally left exhaustive — making itnon_exhaustivewould need a constructor/builder API first, which is out of scope here.Breaking change
Credential,AuthStatusEntry, andAuthLoginResultare public structs without#[non_exhaustive]before this PR; the newrefreshablefield breaks any downstream struct literal that doesn't use..Default::default()or list every field. Updated the 4 affected assertions incli-engine/tests/foundation.rs.#[non_exhaustive]:AuthLoginResultandAuthStatusEntrycan no longer be constructed via struct literal (with or without..Default::default()) or exhaustively pattern-matched from outside this crate. Rewrote the two affected re-export smoke tests infoundation.rsto obtain instances through the real login/status flow instead.Test plan
cargo check --all-targets(default features and--features pkce-auth)cargo clippy --all-targets -- -D warnings(both feature sets)cargo test --all-targets— 613 passed (default features), 665 passed (--features pkce-auth)cargo fmt --checkbuild_credential_sets_refreshable_when_refresh_token_present/build_credential_leaves_refreshable_false_without_refresh_tokeninauth::pkce::tests(refined during review)